<?php

// ini_set("error_reporting", E_ALL);
// ini_set("display_errors","1"); 
// ini_set("ignore_repeated_errors","1");
// ini_set("log_errors", "1" ); 
// ini_set("error_log", "errors/errors_note.php" ); 

include ("php/Lib_Liste.php");
include ("php/Lib_Anote.php");

$string 	= NULL;
$note 		= NULL;
$nom 		= NULL;
$num 		= NULL;
$array_ch 	= NULL;
$other_act 	= " ";

if (isset($_GET['article'])) {$article = $_GET['article'];}
if (isset($_GET['num'])) {$num = $_GET['num'];}
if (isset($_GET['texte'])) {$texte = $_GET['texte'];}
if (isset($_GET['note'])) {$note = $_GET['note'];}

$but_form ="Ajouter";

//$texte = convertSymbolstoEntities($texte);
$texte = stripslashes ($texte);

if ( ereg("article=",$article) ) {
	list($p,$nom) = split("=",$article);
}

if ($nom == NULL) $nom = $article;
	
if (file_exists("data/note/$nom.txt")) {
	$array = note2array($nom);
	if ($num != NULL) {
		$but_form 	= "Modifier";
		$other_act 	= "<input type='submit' name='delete' value='Effacer'>";
		$array_ch 	= return_source($nom,$num);
		$string 	= array2checkboxchecked($array,$array_ch);
	}
	else {
		$string 	= array2checkbox ($array);
	}
}
 

$Echo = "
<html>
<head>
	<link href='default.css' rel='stylesheet' type='text/css'/> 		
</head>
<body>
<div id=\"wrapper\">
	<div id=\"page\">
  	<h1 style=\"padding:10px;\">Add &/or Modify a note </h1>
  	<div class=\"post\" style=\"padding:20px;\">
  	<form action = 'annotation.php' method='post'>
  		<input type='hidden' name='num' value='$num' />
  		<h2>Titre :</h2><input name='nom' value='$nom' readonly='true' style='width:500px; height:25px;'/>
  		<h2>Texte :</h2><input name='texte' value=\"$texte\" style='width:500px; height:25px;'/>
  		<h2>Contenu</h2><textarea rows='9' name='note' cols='50' style='width:500px;'>$note</textarea><br/>
  		<hr/>Related links :<br/>
  		$string
  		<hr/>
  			<input type='submit' name='action' value='$but_form'> $other_act<br/>
  	</form>
  	</div>
  </div>
  <br style=\"clear: both;\" />
</div>
</body>
</html>";

echo $Echo;
?>
